/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.manager;

import br.com.foxline.enums.CivilStatus;
import br.com.foxline.enums.Gender;
import br.com.foxline.model.*;
import br.com.foxline.service.CustomerService;
import br.com.foxline.service.SaleService;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.push.PushContext;
import org.primefaces.push.PushContextFactory;

/**
 *
 * @author luciano
 */
@ManagedBean
@SessionScoped
public class ManagerSale implements Serializable {

    @EJB
    private SaleService saleService;
    @EJB
    private CustomerService customerService;
    private int t = 0;
    private Sale sale;
    private Customer customer;

    @PostConstruct
    public void init() {
        sale = new Sale();
    }

    public void save() {
        System.out.println(sale.getCustomer());
    }

    public ManagerSale() {
        sale = new Sale();

    }

    public List<Customer> autocompleteSale(String query) {
        return customerService.autocomplete(query);
    }

    public Customer getCustomer() {
        return customer;
    }

    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    public Sale getSale() {
        return sale;
    }

    public void setSale(Sale sale) {
        this.sale = sale;
    }

    public void send() {
        t++;
        System.out.print(t);

        PushContext pushContext = PushContextFactory.getDefault().getPushContext();
        pushContext.push("/notifications", new FacesMessage("Test Summary", "Test Detail"));
    }

    public int getT() {
        return t;
    }

    public void setT(int t) {
        this.t = t;
    }
}
